﻿using System;
using System.Collections.Generic;
using HK.Core.Common.Data;
using HK.Core.Common.Protocol.Data;
using HK.Core.Utils;
using HK.Editor.GUIEx.Protocol.Data;
using HK.Editor.Load.Data;

namespace HK.Editor.Load.Protocol.Data
{
    /// <summary>
    /// 接口 : 加载树
    /// </summary>
    /// <typeparam name="TTree">加载树数据类型</typeparam>
    /// <typeparam name="TBranch">加载树枝数据类型</typeparam>
    public interface ILoadTree<TTree, TBranch> : IWindowData, IListJsonData<TBranch>
        where TTree : ListJsonData<TTree, TBranch>
        where TBranch : LoadBranch, IEquatable<TBranch>
    {
        /// <summary>
        /// 加载树枝列表
        /// </summary>
        List<TBranch> Branches { get; }
        
        /// <summary>
        /// 追加加载信息
        /// </summary>
        /// <param name="iBranch">加载数据</param>
        /// <returns>true:追加成功; false:追加失败;</returns>
        bool AddBranch(TBranch iBranch);

        /// <summary>
        /// 追加加载信息
        /// </summary>
        /// <param name="iAssetKey">AssetKey</param>
        /// <param name="iCaller">调用者</param>
        /// <param name="iFrom">从哪里加载(R:Resource; Ab:Atlas; Atlas:SpriteAtlas;)</param>
        /// <param name="iAsync">true:异步; false:同步;</param>
        /// <param name="iSize">大小(既:文件的物理大小。单位:Byte)</param>
        /// <param name="iMemorySize">运存大小(既:文件的物理大小。单位:Byte)</param>
        /// <param name="iCostTime">加载耗时(开始加载性能测试时，才会有效)</param>
        /// <param name="iLoadTime">加载时间</param>
        /// <returns>true:追加成功; false:追加失败;</returns>
        bool AddBranch(string iAssetKey, string iCaller, string iFrom,
            bool iAsync, long iSize, long iMemorySize, long iCostTime, long iLoadTime);
    }
}
